package acm.蓝桥1;

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;
/**
 * https://www.dotcpp.com/oj/problem1434.html
 * 暴力枚举，然后判断是否是回文串
 */
public class 回文串 {
    static int N;
    static int s = 10000;
    static int e = 1000000;
    static PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        boolean has=false;
        for (int i = s; i < e; i++) {
            if (check(i)) {
                pr.println(i);
                has=true;
            }
        }
        if (!has){
            pr.println(-1);
        }
        pr.flush();
    }
    public static boolean check(int n) {
        char[] chars= String.valueOf(n).toCharArray();
        int l=0;
        int r=chars.length-1;
        int res=0;
        int last=0;
        while (l<=r){
            if (chars[l]!=chars[r]){
                return false;
            }
            res+=chars[l]-'0'+chars[r]-'0';
            last=chars[l]-'0';
            l++;
            r--;
        }
        if (chars.length%2!=0){
            res-=last;
        }
        return res==N;
    }
}
